package co.fitstart.entity.market;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import co.fitstart.entity.user.User;

/**
 * 训练记录
 * 
 * @author dan
 *
 */
@Entity
@Table(name = "training_record")
@JsonIgnoreProperties(value={"hibernate_lazy_initializer","handler","fieldHandler"})
public class TrainingRecord {
    
    @Id
    @GeneratedValue
    private Long id;
    
    /** 训练时间 */
    private Date trainingTime;
    
    /** 状态 */
    private TrainingStatus status;
    
    /** 训练单元 */
    private Long dailyId;
    
    /** 用户 */
    private Long userId;
    
    @Column(name = "is_disabled")
    private boolean disabled;
    
    /**
     * The default constructor
     */
    public TrainingRecord() {
        
    }
    
    /**
     * 
     * @param dailyCourseware
     * @param user
     * @param status
     */
    public TrainingRecord(MarketDailyCourseware dailyCourseware, User user, TrainingStatus status) {
        this.trainingTime = new Date();
        this.status = status;
        this.dailyId = dailyCourseware.getId();
        this.userId = user.getId();
        this.disabled = false;
    }
    
    /**
     * 
     * @param status
     * @return
     */
    public TrainingRecord changeStatus(TrainingStatus status) {
        this.status = status;
        return this;
    }
    
    /**
     * 
     * @param date
     * @return
     */
    public TrainingRecord editTrainingTime(Date date) {
        this.trainingTime = date;
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the trainingTime
     */
    public Date getTrainingTime() {
        return trainingTime;
    }

    /**
     * @return the status
     */
    public TrainingStatus getStatus() {
        return status;
    }

    /**
     * @return the dailyId
     */
    public Long getDailyId() {
        return dailyId;
    }

    /**
     * @return the userId
     */
    public Long getUserId() {
        return userId;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param trainingTime the trainingTime to set
     */
    public void setTrainingTime(Date trainingTime) {
        this.trainingTime = trainingTime;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(TrainingStatus status) {
        this.status = status;
    }

    /**
     * @param dailyId the dailyId to set
     */
    public void setDailyId(Long dailyId) {
        this.dailyId = dailyId;
    }

    /**
     * @param userId the userId to set
     */
    public void setUserId(Long userId) {
        this.userId = userId;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

}
